#!/bin/bash

# sudo chmod +x common.sh display.sh kde-config/restore.sh kde-config/backup.sh

source common.sh

print_x_axis 'mirror: 源镜像'
sudo pacman-mirrors -i -c China -m rank

print_x_axis 'system: 更新'
sudo pacman -Syu

print_x_axis 'system: 输入法'
sudo pacman -S fcitx5-im fcitx5-chinese-addons

echo 'GTK_IM_MODULE DEFAULT=fcitx
QT_IM_MODULE  DEFAULT=fcitx
XMODIFIERS    DEFAULT=\@im=fcitx
INPUT_METHOD  DEFAULT=fcitx
SDL_IM_MODULE DEFAULT=fcitx
GLFW_IM_MODULE DEFAULT=ibus
' > ~/.pam_environment

print_x_axis "system: sshkey"
ssh-keygen

print_x_axis "system: neovim"
sudo pacman -S neovim

# print_x_axis "system: podman"
# sudo pacman -S podman
#
# echo 'enable rootless'
#
# sudo mkdir /etc/lxc/
# sudo touch /etc/subuid /etc/subgid /etc/lxc/default.conf
# echo 'lxc.idmap = u 0 100000 65536
# lxc.idmap = g 0 100000 65536' | sudo tee /etc/lxc/default.conf
# echo 'root:100000:65536' | sudo tee /etc/subuid
# echo 'root:100000:65536' | sudo tee /etc/subgid
# echo 'add registries'
#
# echo 'unqualified-search-registries = ["docker.io", "k8s.gcr.io", "quay.io"]
#
# [[registry]]
# prefix = "docker.io"
# location = "hub-mirror.c.163.com"
#
# [[registry.mirror]]
# prefix = "docker.io"
# location = "dockerhub.azk8s.cn"
#
# [[registry]]
# prefix = "k8s.gcr.io"
# location = "gcr.azk8s.cn/google_containers"
#
# [[registry]]
# prefix = "quay.io"
# location = "quay.azk8s.cn"' | sudo tee -a /etc/containers/registries.conf

print_x_axis "software: go"
sudo pacman -S go
go env -w GOPROXY=https://goproxy.cn,direct

print_x_axis "system: base-devel"
sudo pacman -S base-devel

print_x_axis "system: yay"
git clone https://aur.archlinux.org/yay.git
cd yay && GOPROXY=https://goproxy.cn,direct makepkg -si
cd ..

print_x_axis "system: edge"
yay -S aur/microsoft-edge-stable-bin

# print_x_axis "system: vscode"
# pacman -S gnome-keyring libsecret libgnome-keyring
# yay -S aur/visual-studio-code-bin

# print_x_axis "system: oh-my-zsh"
# sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
# cd ..

# kde
# cd kde-config && ./restore.sh
# cd ..

echo "
proxy_on ()
{
    export http_proxy="127.0.0.1:7890";
    export https_proxy="127.0.0.1:7890";
}
proxy_off ()
{
    unset http_proxy;
    unset https_proxy;
}
" >> ~/.zshrc

mkdir -p ~/.cargo
echo "
[source.crates-io]
replace-with = 'tuna'

[source.tuna]
registry = "https://mirrors.tuna.tsinghua.edu.cn/git/crates.io-index.git"
" > ~/.cargo/config

./display.sh
